package com.example.cshaoshao.testall.activities;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.Toast;

import com.example.cshaoshao.testall.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by cshaoshao on 2017/9/4.
 */

public class AllActivity extends AppCompatActivity {
    @BindView(R.id.buttonPop)
    Button button;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.all_layout);
        ButterKnife.bind(this);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showPopupWindow();
            }
        });
    }

    private void showPopupWindow() {
        View view= LayoutInflater.from(this).inflate(R.layout.type_three_activity,null);
        PopupWindow popupWindow=new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT,true);
        view.findViewById(R.id.shenpi).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(AllActivity.this,"你点击了POPUPWindow",Toast.LENGTH_SHORT).show();
            }
        });
        popupWindow.showAtLocation(view, Gravity.CENTER,0,0);
    }
}
